package com.ruoyi.statistics.controller;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.statistics.domain.AgentRank;
import com.ruoyi.statistics.domain.StoreRank;
import com.ruoyi.statistics.service.ISysStatisticsStoreRankService;
import com.ruoyi.system.service.ISysDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 店铺排行榜
 */
@RestController
@RequestMapping("/statistics/statisticsStoreRank")
public class SysStatisticsStoreRankController extends BaseController {
    @Autowired
    public ISysStatisticsStoreRankService sysStatisticsStoreRankService;
    @Autowired
    private ISysDeptService sysDeptService;

    /**
     * 店户排行榜
     * @return
     */
    @GetMapping("/storeRank")
    public AjaxResult storeRank(){

        Long deptId = SecurityUtils.getDeptId();
        SysDept sysDept = sysDeptService.selectDeptById(deptId);
        Map<String,List<StoreRank>> map = new HashMap<>();
        if (sysDept.getType().equals("0")){
            List<StoreRank> allStoreRank = sysStatisticsStoreRankService.allStoreRank();
            map.put("allStoreRank",allStoreRank);
        }
        if (sysDept.getType().equals("1")){
            List<StoreRank> storeRank = sysStatisticsStoreRankService.storeRank(333L);
            map.put("storeRank",storeRank);
        }

        return AjaxResult.success(map);
    }

}
